using NUnit.Framework;

// ReSharper disable InconsistentNaming
namespace NFreeMarker.Tests.Template
{
    public class TemplateTests_ProcessComparisons
    {
        [TestFixture]
        public class When_processing_an_equals_comparison : TemplateTestsBase
        {
            [Test]
            public void Assure_true_is_returned_when_left_value_and_right_value_are_equal()
            {
                SetTemplateContent("${(1 == 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("true"));
            }

            [Test]
            public void Assure_false_is_returned_when_left_value_and_right_value_are_not_equal()
            {
                SetTemplateContent("${(1 == 2)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("false"));
            }
        }

        [TestFixture]
        public class When_processing_a_greater_than_comparison : TemplateTestsBase
        {
            [Test]
            public void Assure_false_is_returned_when_left_value_is_less_than_right_value()
            {
                SetTemplateContent("${(1 > 2)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("false"));
            }

            [Test]
            public void Assure_true_is_returned_when_left_value_is_larger_than_right_value()
            {
                SetTemplateContent("${(2 > 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("true"));
            }

            [Test]
            public void Assure_false_is_returned_when_left_value_and_right_value_are_equal()
            {
                SetTemplateContent("${(1 > 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("false"));
            }
        }

        [TestFixture]
        public class When_processing_a_greater_than_or_equals_comparison : TemplateTestsBase
        {
            [Test]
            public void Assure_false_is_returned_when_left_value_is_less_than_right_value()
            {
                SetTemplateContent("${(1 >= 2)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("false"));
            }

            [Test]
            public void Assure_true_is_returned_when_left_value_is_larger_than_right_value()
            {
                SetTemplateContent("${(2 >= 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("true"));
            }

            [Test]
            public void Assure_true_is_returned_when_left_value_and_right_value_are_equal()
            {
                SetTemplateContent("${(1 >= 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("true"));
            }
        }

        [TestFixture]
        public class When_processing_a_less_than_comparison : TemplateTestsBase
        {
            [Test]
            public void Assure_true_is_returned_when_left_value_is_less_than_right_value()
            {
                SetTemplateContent("${(1 < 2)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("true"));
            }

            [Test]
            public void Assure_false_is_returned_when_left_value_is_larger_than_right_value()
            {
                SetTemplateContent("${(2 < 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("false"));
            }

            [Test]
            public void Assure_false_is_returned_when_left_value_and_right_value_are_equal()
            {
                SetTemplateContent("${(1 < 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("false"));
            }
        }

        [TestFixture]
        public class When_processing_a_less_than_or_equals_comparison : TemplateTestsBase
        {
            [Test]
            public void Assure_true_is_returned_when_left_value_is_less_than_right_value()
            {
                SetTemplateContent("${(1 <= 2)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("true"));
            }

            [Test]
            public void Assure_false_is_returned_when_left_value_is_larger_than_right_value()
            {
                SetTemplateContent("${(2 <= 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("false"));
            }

            [Test]
            public void Assure_true_is_returned_when_left_value_and_right_value_are_equal()
            {
                SetTemplateContent("${(1 <= 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("true"));
            }
        }

        [TestFixture]
        public class When_processing_a_not_equals_comparison : TemplateTestsBase
        {
            [Test]
            public void Assure_false_is_returned_when_left_value_and_right_value_are_equal()
            {
                SetTemplateContent("${(1 != 1)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("false"));
            }

            [Test]
            public void Assure_true_is_returned_when_left_value_and_right_value_are_not_equal()
            {
                SetTemplateContent("${(1 != 2)?string}");

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("true"));
            }
        }
    }
}
// ReSharper enable InconsistentNaming
